package com.shanzmoo.db.sys.entity.vo;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.db.stm.entity.StmSysMenuEntity;
import com.shanzmoo.db.sys.entity.MenuEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * 菜单列表返回对象
 *
 * @author Gzhao
 * @date 2020/11/17
 */
@Data
@Accessors(chain = true)
@ApiModel("菜单列表返回对象")
public class MenuVo {

    @ApiModelProperty("菜单Id" )
    private Integer menuId;

    @ApiModelProperty("菜单名称" )
    private String menuName;

    @ApiModelProperty("菜单类型：0-头部目录，1-左侧一级菜单，2-左侧二级菜单，3-按钮" )
    private Integer menuType;

    @ApiModelProperty("前端路由地址" )
    private String routerUrl;

    @ApiModelProperty("前端组件路径" )
    private String componentPath;

    @ApiModelProperty("权限标识" )
    private String perms;

    @ApiModelProperty("菜单图标" )
    private String menuIco;

    @ApiModelProperty("排序号" )
    private Integer menuIndex;

    @ApiModelProperty("父级菜单" )
    private Integer parentId;

    @ApiModelProperty("子菜单" )
    private List<MenuVo> children;

    public static MenuVo create(MenuEntity menuEntity) {
        return JSON.parseObject(JSON.toJSONString(menuEntity), MenuVo.class);
    }

    public static MenuVo create(StmSysMenuEntity menuEntity) {
        return JSON.parseObject(JSON.toJSONString(menuEntity), MenuVo.class);
    }
}
